package com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.vo.TXingzhengshouwenYijian;

/**
 * A data access object (DAO) providing persistence and search support for
 * TDangweishouwenYijian entities. Transaction control of the save(), update()
 * and delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian
 * @author MyEclipse Persistence Tools
 */

public class TXingzhengshouwenYijianDAO extends HibernateDaoSupport implements ITXingzhengshouwenYijianDAO {
	private static final Log log = LogFactory
			.getLog(TXingzhengshouwenYijianDAO.class);

	protected void initDao() {
		// do nothing
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#save(com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian)
	 */
	public String save(TXingzhengshouwenYijian transientInstance) {
		log.debug("saving TDangweishouwenFujian instance");
		String id = null;
		try {
			id = (String) getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
		return id;
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#delete(com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian)
	 */
	public void delete(TXingzhengshouwenYijian persistentInstance) {
		log.debug("deleting TDangweishouwenYijian instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#findById(java.lang.String)
	 */
	public TXingzhengshouwenYijian findById(java.lang.String id) {
		log.debug("getting TDangweishouwenYijian instance with id: " + id);
		try {
			TXingzhengshouwenYijian instance = (TXingzhengshouwenYijian) getHibernateTemplate()
					.get(
							"com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.vo.TXingzhengshouwenYijian",
							id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#findByExample(com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian)
	 */
	public List findByExample(TXingzhengshouwenYijian instance) {
		log.debug("finding TDangweishouwenYijian instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#findByProperty(java.lang.String, java.lang.Object)
	 */
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding TDangweishouwenYijian instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from TXingzhengshouwenYijian as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#findAll()
	 */
	public List findAll() {
		log.debug("finding all TDangweishouwenYijian instances");
		try {
			String queryString = "from TXingzhengshouwenYijian";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#merge(com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian)
	 */
	public TXingzhengshouwenYijian merge(TXingzhengshouwenYijian detachedInstance) {
		log.debug("merging TDangweishouwenYijian instance");
		try {
			TXingzhengshouwenYijian result = (TXingzhengshouwenYijian) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#attachDirty(com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian)
	 */
	public void attachDirty(TXingzhengshouwenYijian instance) {
		log.debug("attaching dirty TDangweishouwenYijian instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwenYijianDAO#attachClean(com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenYijian)
	 */
	public void attachClean(TXingzhengshouwenYijian instance) {
		log.debug("attaching clean TDangweishouwenYijian instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static ITXingzhengshouwenYijianDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (ITXingzhengshouwenYijianDAO) ctx
				.getBean("TDangweishouwenYijianDAO");
	}
}